Back to course home
0% completed
Vote For New Content
Amazon Hard Problems
Constrained Subsequence Sum (hard)
Solution: Constrained Subsequence Sum
Number of Valid Subarrays (hard)
Solution: Number of Valid Subarrays
Count Vowels Permutation (hard)
Solution: Count Vowels Permutation
Concatenated Words (hard)
Solution: Concatenated Words
Minimum Replacements to Sort the Array (hard)
Solution: Minimum Replacements to Sort the Array
Count All Valid Pickup and Delivery Options (hard)
Solution: Count All Valid Pickup and Delivery Options
Length of the Longest Valid Substring (hard)
Solution: Length of the Longest Valid Substring
Count Array Pairs Divisible by K (hard)
Solution: Count Array Pairs Divisible by K
Word Ladder (hard)
Solution: Word Ladder
Path with Maximum Sum (hard)
Solution: Path with Maximum Sum
Reverse Integer (medium)
Problem Statement
Given a signed 32-bit integer x, return the reverse of x. If the reversed value of x goes beyond the signed 32-bit integer range [-231, 231 - 1], then return 0.
A reverse of x should not contain leading zeros.
Examples
-
Example 1:
- Input: x =
123 - Expected Output:
321 - Justification: Reversing the digits of 123 results in 321, which is within the 32-bit signed integer range.
- Input: x =
-
Example 2:
- Input: x =
-456432 - Expected Output:
-234654 - Justification: Reversing the digits of -456432 results in -234654, maintaining the negative sign and staying within the 32-bit signed integer range.
- Input: x =
-
Example 3:
- Input: x =
1200 - Expected Output:
21 - Justification: Reversing the digits of 1200 results in 0021, but leading zeros are dropped, resulting in 21.
- Input: x =
Try it yourself
Try solving this question here:
Java
. . . .
Solution: Minimum Adjacent Swaps to Make a Valid Array
Solution: Reverse Integer
Mark as Completed
On this page
Problem Statement
Examples
Try it yourself